
<template>
  <div class="wrapper">
    <div class="sub_title">
      <div style="margin-top: var(--safe-top);" class="tit_txt">(六壬起个课APP-日历)</div>
    </div>
    <div class="date_wrapper lr_flex_column_center_box">
      <div @click="() => { if (showCalender == false) { showCalender = true } else { showCalender = false } }"
        class="date_top">
        <div class="left">
          <div class="ganzhi_item">
            <div class="txt" :class="getGzClass(dtopts.ganzhiDate.gzYear[0])">
              {{ dtopts.ganzhiDate.gzYear[0] }}
            </div>
            <div class="txt" :class="getGzClass(dtopts.ganzhiDate.gzYear[1])">
              {{ dtopts.ganzhiDate.gzYear[1] }}
            </div>
            <div class="txt">年</div>
          </div>
          <div class="ganzhi_item">
            <div class="txt" :class="getGzClass(dtopts.ganzhiDate.gzMonth[0])">
              {{ dtopts.ganzhiDate.gzMonth[0] }}
            </div>
            <div class="txt" :class="getGzClass(dtopts.ganzhiDate.gzMonth[1])">
              {{ dtopts.ganzhiDate.gzMonth[1] }}
            </div>
            <div class="txt">月</div>
          </div>
          <div class="ganzhi_item">
            <div class="txt" :class="getGzClass(dtopts.ganzhiDate.gzDay[0])">
              {{ dtopts.ganzhiDate.gzDay[0] }}
            </div>
            <div class="txt" :class="getGzClass(dtopts.ganzhiDate.gzDay[1])">
              {{ dtopts.ganzhiDate.gzDay[1] }}
            </div>
            <div class="txt">日</div>
          </div>
          <div class="ganzhi_item">
            <div class="txt" :class="getGzClass(dtopts.ganzhiDate.gzHour[0])">
              {{ dtopts.ganzhiDate.gzHour[0] }}
            </div>
            <div class="txt" :class="getGzClass(dtopts.ganzhiDate.gzHour[1])">
              {{ dtopts.ganzhiDate.gzHour[1] }}
            </div>
            <div class="txt">时</div>
          </div>
        </div>
        <div class="right box_center">
          <div class="txt">
            {{ dtopts.gongliDate }}<br />
            {{ "农历" + dtopts.yingliDate }}({{
              dtopts.currentJieQi + " " + "星期" + dtopts.weekDay
            }})
          </div>
        </div>
      </div>
      <div class="gz_jiyi">
        <div class="left lr_flex_column_center_box">
          <div class="item lr_flex_row_center_box">
            <div class="icon_txt">月</div><span>{{ currentYuejiang.yueJiang.name }}</span>
            <div class="yjjq">({{
              currentYuejiang.startJieQi + "—" + currentYuejiang.endJieQi
            }})</div>
          </div>
          <div style="margin-top: 10px; " class="item lr_flex_row_center_box">
            <div style="background: green;" class="icon_txt">星</div><span>{{ dtopts.zhiXing }}</span>
          </div>
        </div>
        <div class="right">
          <div class="item">
            <div class="tit">彭祖百忌</div>
            <div class="value">{{ dtopts.pengZu.pzg }} <br />{{ dtopts.pengZu.pzz }}</div>
          </div>
        </div>
      </div>
    </div>
      <nut-calendar-card  @change="changeDate"  class="calendar" style="width: 94vw; height: fit-content"
      v-model="currentDatetime"  ></nut-calendar-card>
 
    <!-- <img src="http://q.qlogo.cn/headimg_dl?dst_uin=3331885126&spec=100" alt=""> -->
  </div>
</template>

<script>


import { formatToChineseDateTime } from "../api/jieLi";
import { Calendar } from "vant";
import { CalendarCard } from "@nutui/nutui";
import { getGzClass } from "../api/styleUtils";
import { getCurrentYueJiangAndJieQi } from "../api/yuejiang";
import Database from '@tauri-apps/plugin-sql'
import { showToast } from '@nutui/nutui'
import { Store, getStore } from '@tauri-apps/plugin-store';
import { selectByValue } from '../api/dbUtils';
import { onBackKeyDown } from 'tauri-plugin-app-events-api';

export default {
  name: "Test",
  components: {
    Calendar,
    NutCalendarCard: CalendarCard,
  },
  props: {},
  data() {
    return {
      currentDatetime: new Date(),
      shensha: null,
      dtopts: null,
      getGzClass: getGzClass,
      currentYuejiang: null,
      showCalender: false,
      v: '',
      searchValue: '',
      showSearchContent: false
    };
  },
  async created() {
     this.dtopts = formatToChineseDateTime(this.currentDatetime);
    this.currentYuejiang = getCurrentYueJiangAndJieQi(this.dtopts.currentJieQi);
    onBackKeyDown(() => {
      if (this.showSearchContent !== false) {
        this.onCancelSearch()
      }
      return true;
    })
   
  },
  methods: {    
    changeDate(v) {
      this.dtopts = formatToChineseDateTime(v);
    this.currentYuejiang = getCurrentYueJiangAndJieQi(this.dtopts.currentJieQi);
    }
  },
  mounted() {
   
  }
};
</script>

<style lang="scss" scoped>
$cbgc: var(--lr_lbgc);
.wrapper {
  background-color: white;
  position: fixed;
  top: 0;
  left: 0;
  overflow: scroll;
  height: calc(100vh);
  width: 100vw;
  // background: url('../assets/素材/chatu.png');
  background-repeat: no-repeat;
  background-size: cover;
  /* 关键属性：保持比例并覆盖整个容器 */
  background-position: center;
  /* 居中显示 */

  /* 不重复 */
  background-attachment: fixed;
  display: flex;
  flex-direction: column;
  align-items: center;

  .sub_title {
    width: 100vw;
    background-color: var(--nav_bg_color);
    display: flex;
    flex-direction: column-reverse;

    .tit_txt {
      width: 100vw;
      height: 30rem;
      line-height: 30rem;
      font-size: 17rem;
      font-weight: bolder;
      text-align: center;
      background-color: var(--nav_bg_color);
      color: black;
    }
  }
  .date_wrapper {
    height: fit-content;
    width: fit-content;
    margin-top: 20rem;
    border-radius: 6px;
    overflow: hidden;
flex-shrink: 0;
    .date_top {
      padding: 1vw;
      width: 92vw;
      display: flex;
      background-color: $cbgc;
      padding-bottom: 5px;

      .left {
        margin-top: 5rem;
        display: flex;
        width: fit-content;
        height: fit-content;
        display: flex;

        .txt {
          // background-color: #d41c1c;
          height: 23rem;
          width: 23rem;
          line-height: 23rem;
          text-align: center;
          font-size: 15rem;
          font-weight: 700;
          // border: 1px solid rebeccapurple;
        }
      }

      .right {
        color: var(--btn_fbg_color);
        margin-top: 5rem;
        text-align: center;
        flex-grow: 1;
        line-height: 23rem;
        font-size: 14rem;
        font-weight: 500;

        .txt {
          max-width: 90%;
          height: fit-content;
          color: rgb(0, 0, 0);
        }
      }
    }

    .gz_jiyi {
      height: 80rem;
      width: 94vw;
      display: flex;
      overflow: hidden;
      background-color: $cbgc;
      border-top: 1px solid #d4d4d4;

      .left {
        border-right: 1px solid #d4d4d4;
        height: 80rem;
        width: 50%;
        align-items: flex-start;

        .item {
          flex-direction: row;
          width: fit-content;
          margin-left: 10px;

          .icon_txt {
            height: 26px;
            width: 26px;
            font-size: 14px;
            font-weight: bold;
            line-height: 26px;
            text-align: center;
            border-radius: 50%;
            color: rgb(255, 255, 255);
            background-color: #ff0000;
          }

          span {
            margin-left: 10px;
            font-size: 16px;
            font-weight: bold;
          }

          .yjjq {
            font-size: 14px;
            counter-reset: #6e6e6e;
          }
        }
      }

      .right {
        text-align: center;
        display: flex;
        justify-content: center;
        align-items: center;
        height: 80rem;
        width: 50%;
        // border-left: 0.5px solid #4d4d4d;

        .tit {
          color: var(--txt_secu_color);
          font-size: 14rem;
          font-weight: 700;
          height: 26rem;
          line-height: 6rem;
          margin-top: 5rem;
        }

        .value {
          line-height: 23rem;
          font-size: 13rem;
        }
      }
    }
  }
    .calendar {
    margin-top: 10px;
    background-color: $cbgc;
    border-radius: 6px;
flex-shrink: 0;
    ::v-deep(.nut-calendarcard-day) {
      height: 34px;
      border-radius: 3px;
    }

    ::v-deep(.nut-calendarcard-header) {
      height: 34px;
    }
  }
  .search_wrapper {
    transition: margin-top 0.3s ease;
    border: 1.5px solid var(--cart_bg_color);
    display: flex;
    align-items: center;
    margin-top: 10px;
    height: 5rem;
    width: 86vw;
    background-color: #ffffff;
    border-radius: 2.5rem;
    line-height: 5rem;

    .left {
      width: 5rem;
      height: 3rem;
      line-height: 3rem;
      text-align: center;
      font-size: 2.26rem;
    }

    input {
      background-color: #ffffff;
      border: none;
      outline: none;
      height: calc(5rem - 2px);
    }

    input::-webkit-search-cancel-button {
      display: none;
    }

    .mid {
      width: calc(86vw - 12.8rem);
      font-size: 2rem;
      overflow-x: auto;
      white-space: nowrap;
      /* 禁止文本换行 */
      overflow-x: auto;
      /* 内容超出时显示水平滚动条 */
      overflow-y: hidden;
      /* 隐藏垂直滚动条 */

      /* 设置固定宽度 */
      /* 可选：平滑滚动效果 */
      scroll-behavior: smooth;
    }

    .right {
      width: 5rem;
      height: 3rem;
      line-height: 3rem;
      text-align: center;
      font-size: 1.6rem;
      background-color: #2377dd;
      border-radius: 1.8rem;
      margin-right: 1rem;
      margin-left: 1rem;
      color: white;
      padding-left: 0.4rem;
      padding-right: 0.4rem;
    }

    .right:active {
      transition: transform 0.3s ease;
      transform: scale(1.2)
    }

    .editable-div {
      // border: 1px solid #ddd;
      border-radius: 6px;
      /* 确保有足够编辑空间 */
      outline: none;
      /* 移除默认聚焦边框 */
    }

    /* 聚焦时的样式 */
  }


  .content {
    width: 90vw;
    height: fit-content;

    .search_bcc_content {
      // transition: transform 0.3s ease;
      width: 90vw;
      height: 77rem;
      background-color: #ffffff;
    }

    .menu_content {
      transition: transform 0.3s ease;
      height: fit-content;
      display: flex;
      justify-content: space-around;
      flex-wrap: wrap;
      width: 90vw;

      .menu_item {
        margin-top: 1rem;
        display: flex;
        flex-direction: column;
        align-items: center;
        font-size: 1.6rem;

        img {
          border-radius: 0.5rem;
          width: 4.6rem;
          height: 4.6rem;
        }
      }

    }

  }
}
</style>